package com.foreverwin.mes.mq.listener;

import com.foreverwin.mes.common.model.EapLog;
import com.foreverwin.mes.common.service.EapLogService;
import com.foreverwin.mes.core.utils.ObjectMapperUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;

/**
 * EAP日志记录
 *
 * @author Ervin Chen
 * @date 2020/3/19 14:33
 */
@Component
public class EapLogListener {

    @Autowired
    EapLogService eapLogService;

    @JmsListener(destination = "MES_EAP_LOG")
    public void saveEapLog(String eapLogJson) {
        EapLog eapLog = null;
        try {
            eapLog = ObjectMapperUtil.readValue(eapLogJson, EapLog.class);
            eapLogService.insert(eapLog);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
